<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>

<!-- ========================= -->
<!-- root element: partNumbersAcknowledgement -->
<!-- ========================= -->


<xsl:template match="partNumbersAcknowledgement">

	<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

	<fo:layout-master-set>
		<fo:simple-page-master master-name="simpleA4"
        		page-height="8.27in"
        		page-width="11.69in"
        		margin-top="10mm"
        		margin-bottom="0.30in"
      			margin-left="7mm"
      			margin-right="10mm" >

            <fo:region-before extent="32mm"/>

			<fo:region-after extent="8mm"/>

			<fo:region-body margin-top="28mm" margin-bottom="0.65in"/>

  		</fo:simple-page-master>
	</fo:layout-master-set>


<fo:page-sequence master-reference="simpleA4">

<!--============================== -->
<!-- Header block             -->
<!--============================== -->
    <fo:static-content flow-name="xsl-region-before">

    <fo:block font-size="8pt" space-after="0.5cm">
	<fo:table margin="2mm" table-layout="fixed" width="100%">

	<fo:table-column column-width="50mm"/>
	<fo:table-column column-width="90mm"/>
	<fo:table-column column-width="80mm"/>
	<fo:table-column column-width="40mm"/>

<!--==============================-->
<!-- Logo and Self address block  -->
<!--==============================-->

	<fo:table-body>
		<fo:table-row>

			<fo:table-cell >
			    <xsl:apply-template match="logo">
				<fo:external-graphic content-height = ".1in"  content-width = ".1in" >
					<xsl:attribute name="src" >
						<xsl:value-of select="logo" />
					</xsl:attribute>
				</fo:external-graphic>
			    </xsl:apply-template>
		    </fo:table-cell>

            <fo:table-cell >
                <xsl:apply-template match="selfAddress">
                <fo:block font-size="13pt" font-weight="bold"><xsl:value-of select="selfAddress//name" /></fo:block>
                <fo:block font-size="8pt"><xsl:value-of select="selfAddress//address1" /></fo:block>
                <fo:block font-size="8pt"><xsl:value-of select="selfAddress//address2" /></fo:block>
                <fo:block font-size="8pt"><xsl:value-of select="selfAddress//cityStateZip" /></fo:block>
                <fo:block font-size="8pt"><xsl:value-of select="selfAddress//phoneFax" /></fo:block>
                <fo:block font-size="8pt"><xsl:value-of select="selfAddress//webSite" /></fo:block>
                </xsl:apply-template>
            </fo:table-cell>

            <fo:table-cell text-align="left" width="100%">
                <fo:block font-size="15pt" font-weight="bold" display-align="center"><xsl:value-of select="custPartNumberLabel"/>s</fo:block>
            </fo:table-cell>

			<fo:table-cell text-align="right" width="100%">
                <fo:block font-size="13pt" font-weight="bold" text-align="right">Date: <xsl:value-of select="date" /></fo:block>
            </fo:table-cell>

		</fo:table-row>
	</fo:table-body>
	</fo:table >
	</fo:block>

    </fo:static-content>




<fo:flow flow-name="xsl-region-body">
    <fo:block font-size="10pt" font-weight="bold" space-before="5mm" text-align="center">
        Customer Name: <xsl:apply-templates select="customerName"/>
    </fo:block>
    <fo:block font-size="8pt" space-before="10mm">
        <xsl:apply-templates select="partNumbers"/>
    </fo:block>

<!-- Inorder to get page count -->

<fo:block id="endofdoc"></fo:block>
</fo:flow>

</fo:page-sequence>
</fo:root>
</xsl:template>


<!-- ================================ -->
<!--	child element: Self Address     -->
<!-- ================================ -->

<xsl:template match="selfAddress">
	<fo:table width="100%" table-layout="fixed">
	<fo:table-column />
		<fo:table-body>
			<fo:table-row>
				<fo:table-cell text-align="center">

					<fo:block font-weight="bold">Self Address:</fo:block>
					<fo:block><xsl:value-of select="name"/></fo:block>
					<fo:block><xsl:value-of select="address1"/></fo:block>
					<fo:block><xsl:value-of select="address2"/></fo:block>
					<fo:block><xsl:value-of select="address3"/></fo:block>
					<fo:block><xsl:value-of select="phone"/></fo:block>
					<fo:block><xsl:value-of select="fax"/></fo:block>
					<fo:block>Email: <xsl:value-of select="email"/></fo:block>

				</fo:table-cell>
			</fo:table-row>
		</fo:table-body>
	</fo:table>
</xsl:template>



<!-- ===================================  -->
<!--	child element:Part Numbers. 	     -->
<!-- =================================== -->

<xsl:template match="partNumbers">
	<fo:block >
        <fo:table margin="2mm" width="100%" border="1pt double black"  background-color="#DEE1E2" table-layout="fixed">
            <fo:table-column column-width="280mm"/>
                <fo:table-body>
                    <fo:table-row height="0.7cm" border="1pt double black" background-color="#DEE1E2">
                        <fo:table-cell border="1pt double black">
                        <fo:table margin="2mm" width="100%" background-color="#DEE1E2" table-layout="fixed">
                            <fo:table-column/>
                            <fo:table-column/>
                            <fo:table-column/>
                            <fo:table-column/>

                            <fo:table-body>
                            <fo:table-row height="0.7cm" border="1pt double black" background-color="#DEE1E2">
                                <fo:table-cell border="1pt double black" display-align="center" >
                                    <fo:block space-before="1mm"/>
                                    <fo:block font-size="8pt" font-weight="bold" text-align="left">
                                        <xsl:value-of select="mfgPartNumberLabel"/>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border="1pt double black" display-align="center" >
                                    <fo:block space-before="1mm"/>
                                    <fo:block font-size="8pt" font-weight="bold" text-align="left">
                                        <xsl:value-of select="custPartNumberLabel"/>
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border="1pt double black" display-align="center" >
                                    <fo:block space-before="1mm"/>
                                    <fo:block font-size="8pt" font-weight="bold" text-align="left">ODM Name</fo:block>
                                </fo:table-cell>
                                <fo:table-cell border="1pt double black" display-align="center" >
                                    <fo:block space-before="1mm"/>
                                    <fo:block font-size="8pt" font-weight="bold" text-align="left">
                                        <xsl:value-of select="labelNumberLabel"/>
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                           </fo:table-body>
                         </fo:table>
                        </fo:table-cell>
                     </fo:table-row>
                     <fo:table-row height="0.7cm" background-color="#DEE1E2">
                         <fo:table-cell border="1pt double black">
                         <fo:table margin="2mm" width="100%" background-color="#DEE1E2" table-layout="fixed">
                            <fo:table-column/>
                            <fo:table-column/>
                            <fo:table-column/>
                            <fo:table-column/>
                                 <fo:table-body>
                                     <xsl:for-each select="/partNumbersAcknowledgement/partNumbers">
                                            <xsl:for-each select="partNumber">
                                                <xsl:if test="title='true'">
                                                     <xsl:if test="bgCount='false'">
                                                            <fo:table-row height="0.4cm" background-color="#FFFFEE">
                                                                <fo:table-cell  number-columns-spanned = "4">
                                                                    <fo:block space-before="1mm"/>
                                                                    <fo:block font-size="8pt" text-decoration="underline" font-weight="bold" text-align="center">
                                                                        <xsl:value-of select="mfgPartNumber"/>
                                                                    </fo:block>
                                                                </fo:table-cell>
                                                            </fo:table-row>
                                                     </xsl:if>
                                                     <xsl:if test="bgCount='true'">
                                                            <fo:table-row height="0.4cm" background-color="#DEE1E2">
                                                                <fo:table-cell  number-columns-spanned = "4">
                                                                    <fo:block space-before="1mm"/>
                                                                    <fo:block font-size="8pt" text-decoration="underline" font-weight="bold" text-align="center">
                                                                        <xsl:value-of select="mfgPartNumber"/>
                                                                    </fo:block>
                                                                </fo:table-cell>
                                                            </fo:table-row>
                                                     </xsl:if>
                                                </xsl:if>
                                                <xsl:if test="title='false'">
                                                    <xsl:if test="bgCount='false'">
                                                        <fo:table-row background-color="#FFFFEE">
                                                            <fo:table-cell>
                                                                <fo:block space-before="1mm"/>
                                                                <fo:block font-size="8pt" text-align="left">
                                                                    <xsl:value-of select="mfgPartNumber"/>
                                                                </fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell>
                                                                <fo:block space-before="1mm"/>
                                                                <fo:block font-size="8pt" text-align="left">
                                                                    <xsl:value-of select="custPartNumber"/>
                                                                </fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell>
                                                                <fo:block space-before="1mm"/>
                                                                <fo:block font-size="8pt" text-align="left">
                                                                    <xsl:value-of select="odmName"/>
                                                                </fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell>
                                                                <fo:block space-before="1mm"/>
                                                                <fo:block font-size="8pt" text-align="left">
                                                                    <xsl:value-of select="labelNumber"/>
                                                                </fo:block>
                                                            </fo:table-cell>
                                                        </fo:table-row>
                                                    </xsl:if>
                                                    <xsl:if test="bgCount='true'">
                                                        <fo:table-row background-color="#DEE1E2">
                                                            <fo:table-cell>
                                                                <fo:block space-before="1mm"/>
                                                                <fo:block font-size="8pt" text-align="left">
                                                                    <xsl:value-of select="mfgPartNumber"/>
                                                                </fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell>
                                                                <fo:block space-before="1mm"/>
                                                                <fo:block font-size="8pt" text-align="left">
                                                                    <xsl:value-of select="custPartNumber"/>
                                                                </fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell>
                                                                <fo:block space-before="1mm"/>
                                                                <fo:block font-size="8pt" text-align="left">
                                                                    <xsl:value-of select="odmName"/>
                                                                </fo:block>
                                                            </fo:table-cell>
                                                            <fo:table-cell>
                                                                <fo:block space-before="1mm"/>
                                                                <fo:block font-size="8pt" text-align="left">
                                                                    <xsl:value-of select="labelNumber"/>
                                                                </fo:block>
                                                            </fo:table-cell>
                                                        </fo:table-row>
                                                    </xsl:if>
                                                </xsl:if>
                                            </xsl:for-each>
                                    </xsl:for-each>
                               </fo:table-body>
                           </fo:table>
                         </fo:table-cell>
                       </fo:table-row>
                </fo:table-body>
	    </fo:table>
	</fo:block>
</xsl:template>

</xsl:stylesheet>